#!/usr/bin/python

import commands

target = "firefox"
#target = "bash"

(status, output) = commands.getstatusoutput('pgrep %s'%target)
if status == 0:
	pids = len(output.split('\n'))
	print "find %d pids"%pids
	if pids > 1:
		print "will kill all process...."
		for pid in output.split('\n'):
			print "kill pid: %s"%pid
		print "restart process...."
	else:
		print "ok, find required thing"
else:
	print "can't find process %s"%target

